<%--
  Created by IntelliJ IDEA.
  User: cjrh2
  Date: 2025/11/6
  Time: 20:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>Title</title>
    <script src="jquery-3.7.1.min.js"></script>
</head>
<body>

<a href="http://localhost:8080/mvc/book/test2?username=admin">访问另一个服务器的控制器</a>


<hr>

<%--
<script>
    $(document).ready(function () {
        $.ajax({
            url: "http://localhost:8080/mvc/api/data",  // 跨域请求
            type: "GET",
            success: function (data) {
                console.log("成功:", data);
            },
            error: function (xhr, status, error) {
                console.error("跨域失败:", status, error);
            }
        });
    });
</script>
--%>

<button id="btn">异步请求服务器资源</button>

<script>
    $('#btn').click(function () {
        $.ajax({
            url: 'http://localhost:8080/mvc/api/login',
            type: 'POST',
            contentType: 'application/json',
            success: function (data) {
                console.log(data.name)
                console.log(data.age)
                console.log(data.address)
                console.log(data.gender)
            }
        });
    });

</script>
</body>
</html>
